package com.pi2e.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.pi2e.R;
import com.pi2e.common.KdxfSpeechHelper;
import com.pi2e.common.KdxfSpeechHelper.SpeechCompletedListener;
import com.pi2e.view.base.BaseActivity;
import com.pi2e.view.common.FootView;
import com.pi2e.view.common.HeaderView;

public class CommentRobotActivity extends BaseActivity implements OnClickListener {
	
	View mfootview ;
	View mHeadView ;
	 
	String title="亲爱的刘女士，您的房间到了" ;
	String content = "您对大艺的服务还满意吗?" ;
	ImageView mImgLogo ;
	
	Handler handler = new Handler() ;
	Runnable runEnd = new Runnable() {
		
		@Override
		public void run() {
			Intent it = new Intent(CommentRobotActivity.this,EndGuideActivity.class) ;
			startActivity(it);
			finish();
		}
	};
	Runnable runStart = new Runnable() {
		
		@Override
		public void run() {
			KdxfSpeechHelper.startPlay(title+"，"+content, new SpeechCompletedListener() {
				
				@Override
				public boolean onPreperPlay() {
					// TODO Auto-generated method stub
					return false;
				}
				
				@Override
				public boolean onPlay(String Msg) {
					// TODO Auto-generated method stub
					return false;
				}
				
				@Override
				public boolean onError() {
					// TODO Auto-generated method stub
					return false;
				}
				
				@Override
				public boolean onCompleted() {
					handler.postDelayed(runEnd, KdxfSpeechHelper.AFTER_SPEECH_DELAY_TIME+6000) ;
					return false;
				}
			});
			
			
		}
	};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		handler.postDelayed(runStart, KdxfSpeechHelper.BEFORE_SPEECH_DELAY_TIME) ;
	}
	@Override
	public HeaderView initHeaderView() {
		HeaderView hv = new HeaderView(findViewById(R.id.headId),this) ;
		hv.getTitle_Tv().setText(title);
		return hv;
	}

	@Override
	public void setContentView() {
		setContentView(R.layout.activity_guidevip);

	}

	@Override
	public void initView() {
		mfootview = findViewById(R.id.footId) ;
		mHeadView = findViewById(R.id.headId) ;
		TextView txt_content = (TextView) findViewById(R.id.txt_guide);
		txt_content.setText(content);
		mImgLogo = (ImageView) findViewById(R.id.img_logo) ;
		mImgLogo.setImageResource(R.drawable.test_comment_01);
	}

	@Override
	public void initFootView() {
		FootView footView = new FootView(CommentRobotActivity.this, mfootview) ;
		footView.getBtn_ok().setText("退 出");
		footView.getBtn_ok().setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				
				finish();
			}
		});
	}

	@Override
	public void onClick(View v) {
		int vid = v.getId() ;
		switch (vid) {
		case R.id.img_logo:
			
			break;

		default:
			break;
		}
		
	}
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		if (null != handler && null !=runStart) {
			KdxfSpeechHelper.onDestroy();
			handler.removeCallbacks(runStart);
		}
	}
	
}
